package com.eBook.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.eBook.entity.Book;
import com.eBook.entity.BookType;
import com.eBook.service.BookTypeService;

@Controller
@RequestMapping("/booktype")
public class BookTypeController {

	@Autowired
	BookTypeService bookTypeService;
	
	/**
	 * 找到所有的类别
	 * @return
	 */
	@RequestMapping(value="/", method=RequestMethod.GET)
	@ResponseBody
	public List<BookType> findAllType() {
		return bookTypeService.findAllType();
	}
	
	/**
	 * 找到本类别下的所有书籍
	 * @param typeId
	 * @return
	 */
	@RequestMapping(value="/{bookTypeId}", method=RequestMethod.GET)
	@ResponseBody
	public List<Book> findBookByTypeId(@PathVariable("bookTypeId") String typeId) {
		return bookTypeService.findBookByTypeId(typeId);
	}
}
